<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <form name="f1">
      <p>username <input type="text" name="username" value="lili" /></p>
    </form>
    <script>
      const form = document.f1;
      // onchange当值发生变化，输入框失去焦点
      form.username.onchange = function () {
        console.log("onchange");
      };

      // 用户输入事件
      form.username.oninput = function () {
        console.log("oninput");
      };

      // 复制
      form.username.oncopy = function () {
        console.log("oncopy");
      };

      // 剪切
      form.username.oncut = function () {
        console.log("oncut");
      };

      // 粘贴
      form.username.onpaste = function () {
        console.log("onpaste");
      };
    </script>
  </body>
</html>
